<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/css/base2.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/css/style2.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
<title>渠道商管理-渠道商账户</title>
</head>
<body>
	<div class="page">
		<div class="main_menu fl">
			<c:forEach items="${sessionScope.MENU_LIST}" var="mainMenu">
				<c:if test="${mainMenu.wOOpid == 2}">
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/${mainMenu.wOAction}"
							target="main"> <img
							src="${pageContext.request.contextPath}${mainMenu.wOIcon}">
							<p>${mainMenu.wOName}</p>
						</a>
					</div>
				</c:if>
			</c:forEach>
		</div>
			<div class="main_cont fl">
				<div class="main_cont_top">
					<div class="main_inner clearfix">

						<div class="cont_top_time fr">
						
						</div>
					</div>
				</div>
				<!-- <div class="main_cont_top">
						<div class="main_inner clearfix">
							<div class="cont_top_time fr pr">
								<form>
									<input type="search" placeholder="请输入人员姓名、手机号查询" class="search_txt">
									<input type="submit" value="搜索" class="search pa" style="top:6px;right: 0;">
								</form>
							</div>
						</div>
					</div> -->
				<div class="main_cont_bottom">
					<div class="main_inner">
						<div class="add_mian">
							<form
								action="${pageContext.request.contextPath}/supplier/edit.html"
								method="post" id="myform">
								<div class="zhuce_box pb20">
									<div class="shanghuxx clearfix" style="height: 300px;">
										<div class="shanghuxx_l fl" style="height: 280px;">商户信息</div>
										<div class="shanghuxx_r fl" style="height: 280px;">
											<p>
												<span>商户名称：</span><input type="text" class="input_txt"
													id="wSName" name="wSName" value="${supplier.wSName}"><i
													class="ml15 c999">请确保商户名称与企业资质上一致！</i>
											</p>
											<p>
												<span>公司地址：</span><select class="gsdz" name="wSCity"
													id="wSCity">
													<option value="重庆">重庆</option>
												</select> <select class="gsdz" name="wSDistrict" id="wSDistrict">
													<option value="">请选择区(县)</option>
													<option value="渝中区" selected>渝中区</option>
													<option value="南岸区">南岸区</option>
													<option value="江北区">江北区</option>
													<option value="沙坪坝区">沙坪坝区</option>
													<option value="九龙坡">九龙坡</option>
													<option value="巴南区">巴南区</option>
													<option value="渝北区">渝北区</option>
													<option value="大渡口区">大渡口区</option>
													<option value="北碚区">北碚区</option>
													<option value="綦江区 ">綦江区</option>
													<option value="长寿区">长寿区</option>
													<option value="江津区">江津区</option>
													<option value="合川区">合川区</option>
													<option value="永川区">永川区</option>
													<option value="南川区">南川区</option>
													<option value="铜梁区">铜梁区</option>
													<option value="潼南区">潼南区</option>
													<option value="黔江区">黔江区</option>
													<option value="荣昌区">荣昌区</option>
													<option value="璧山区">璧山区</option>
													<option value="万州区">万州区</option>
													<option value="涪陵区">涪陵区</option>
												</select> <input type="text" class="input_long" name="wSAddress"
													id="wSAddress" value="${supplier.wSAddress}">
											</p>

											<div class="clearfix yewu">
												<p class="fl">主营业务：</p>
												<input type="text" class="input_long" name="wSObject"
													id="wSObject" value="${supplier.wSObject}" />
											</div>
											<div class="clearfix quyu">
												<p class="fl">目标服务区域：</p>
												<input type="text" class="input_long"
													name="wSServuceDistrict" id="wSServuceDistrict"
													value="${supplier.wSServuceDistrict}" />
											</div>
										</div>
									</div>
									<div class="lianxixx clearfix" style="height: 180px;">
										<div class="lianxixx_l fl" style="height: 150px;">联系信息</div>
										<div class="lianxixx_r fl" style="height: 150px; float: left;">
											<p>
												<span>商户联系人：</span><input type="text" class="input_txt"
													name="wSContact" id="wSContact"
													value="${supplier.wSContact}">
											</p>
											<p>
												<span>联系人电话：</span><input type="text" class="input_txt"
													name="wSTelephone" id="wSTelephone"
													value="${supplier.wSTelephone}">
											</p>
										</div>
									</div>
									<div class="qiyezhizi clearfix">
										<div class="qiyezhizi_l fl">企业资质</div>
										<div class="qiyezhizi_r fl pr">
											<img
												src="${pageContext.request.contextPath}/attach/images/${supplier.wSAttacId}.jpg"
												id="headimage" name="headimage"
												style="width: 320px; height: 200px;"> <input
												type="file" class="file" id="headerpic" name="headerpic"
												onchange="showPicture()">
										</div>
									</div>
									<div class="zc_btn">
										<input type="button" value="确认添加" class="zc_add"
											onclick="tijiao();">
									</div>
								</div>
								<input type="hidden" name="id" value="${supplier.id}" /> <input
									type="hidden" name="wSAttacId" id="wSAttacId" />

							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script>
		$(".yewu li").click(function() {
			if ($(this).hasClass("on")) {
				$(this).removeClass("on");
			} else {
				$(this).addClass("on");
			}
		});
		$(".quyu li").click(function() {
			if ($(this).hasClass("on")) {
				$(this).removeClass("on");
			} else {
				$(this).addClass("on");
			}
		});

		//兼容性浏览器
		function getObjectURL(file) {
			var url = null;
			if (window.createObjectURL != undefined) { // basic
				url = window.createObjectURL(file);
			} else if (window.URL != undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file);
			} else if (window.webkitURL != undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file);
			}
			return url;
		}
		//上传图片
		function showPicture() {
			var strsrc = getObjectURL($("#headerpic").get(0).files[0]);
			$("#headimage").attr("src", strsrc);

			var formData = new FormData();
			formData.append("file", $("#headerpic").get(0).files[0]);

			$.ajax({
				type : "post",
				url : "/file/upload.json",
				data : formData,
				// 告诉jQuery不要去处理发送的数据
				processData : false,
				// 告诉jQuery不要去设置Content-Type请求头 
				contentType : false,
				success : function(data) {
					$("#wSAttacId").val(data.info);
				}
			});

		}

		function logins() {
			window.location = "${pageContext.request.contextPath}/manager/login.html";
		}

		function tijiao() {
			var wSName = $("#wSName").val();
			if (wSName == null || wSName == "") {
				alert("商户名称不能为空！");
				return false;
			}
			var wSCity = $("#wSCity").val();
			if (wSCity == null || wSCity == "") {
				alert("请选择城市！");
				return false;
			}
			var wSDistrict = $("#wSDistrict").val();
			if (wSDistrict == null || wSDistrict == "") {
				alert("请选择区域！");
				return false;
			}
			var wSAddress = $("#wSAddress").val();
			if (wSAddress == null || wSAddress == "") {
				alert("请输入公司地址！");
				return false;
			}
			/* var wAUsername=$("#wAUsername").val();
			if(wAUsername==null || wAUsername==""){
				alert("请输入用户名！");
				return false;
			}
			var wAPassword=$("#wAPassword").val();
			if(wAPassword==null || wAPassword==""){
				alert("请输入密码！");
				return false;
			}
			var password=$("#password").val();
			if(password==null || password==""){
				alert("请输入确认密码！");
				return false;
			}
			if(password!=wAPassword){
				alert("请输入密码和确认密码不一致！");
				return false;
			} */
			var wSContact = $("#wSContact").val();
			if (wSContact == null || wSContact == "") {
				alert("请输入商户联系人！");
				return false;
			}
			if (wSContact.length > 8) {
				alert("请输入不超过8个字的商户联系人！");
				return false;
			}
			var wSTelephone = $("#wSTelephone").val();
			if (wSTelephone == null || wSTelephone == "") {
				alert("请输入联系电话！");
				return false;
			}
			if (!(/^1(3|4|5|7|8)\d{9}$/.test(wSTelephone))) {
				alert("请输入有效的手机号码！");
				return false;
			}

			/* var strs="";
			var wSObject2=$("#wSObject2").find("li");
			for(i=0;i<wSObject2.length;i++){ 
				if($(wSObject2[i]).hasClass("on")){
					strs+=" "+wSObject2[i].innerHTML;
				} 
			}
			$("#wSObject").val(strs);
			
			var serv="";
			var wSServuceDistrict2=$("#wSServuceDistrict2").find("li");
			for(i=0;i<wSServuceDistrict2.length;i++){ 
				if($(wSServuceDistrict2[i]).hasClass("on")){
					serv+=" "+wSServuceDistrict2[i].innerHTML;
				} 
			}
			$("#wSServuceDistrict").val(serv); */

			$("#myform").submit();
		}

		/* $(function(){
		
				$("#wAUsername").change(function() {
					var username = $("#wAUsername").val();
					$.ajax({
						  url: "${pageContext.request.contextPath}/manager/check/"+ username + ".json",
						  success:function(data) {
							
							  if(data == 0) {
								alert("用户名已存在！");
								$("#wAUsername").val("");
							  }
						  }
						});
				});
		}); */
	</script>
</body>
</html>
